// import echarts from 'echarts'
import echarts from 'echarts/lib/echarts'
export const LineOption = {
  tooltip: {
    trigger: 'axis',
    axisPointer: { // 坐标轴指示器，坐标轴触发有效
      type: 'line' // 默认为直线，可选为：'line' | 'shadow'
    }
  },
  xAxis: {
    type: 'category',
    boundaryGap: true,
    nameGap: 5,
    nameLocation: 'end',
    nameTextStyle: {
      color: '#fff',
      fontSize:10
    },
    data: [],
    axisLabel: {
      textStyle: {
        color: 'rgba(255,255,255,0.58)',
        fontSize: 12
      },
      show: true,
      interval: 0,
      formatter: function (params) {
        var newParamsName = "";
        var paramsNameNumber = params.length;
        var provideNumber = 4; //一行显示几个字
        var rowNumber = Math.ceil(paramsNameNumber / provideNumber);
        if (paramsNameNumber > provideNumber) {
          for (var p = 0; p < rowNumber; p++) {
            var tempStr = "";
            var start = p * provideNumber;
            var end = start + provideNumber;
            if (p == rowNumber - 1) {
              tempStr = params.substring(start, paramsNameNumber);
            } else {
              tempStr = params.substring(start, end) + "\n";
            }
            newParamsName += tempStr;
          }

        } else {
          newParamsName = params;
        }
        return newParamsName
      },
    },
    axisLine: {
      show: true,
      lineStyle: {
        color: 'rgba(255,255,255,0.22)'
      }
    }
  },
  grid: {
    bottom: 35,
    top: 20,
    left: 50,
    right: 10
  },
  yAxis: {
    type: 'value',
    boundaryGap: true,
    nameGap: 5,
    nameLocation: 'end',
    nameTextStyle: {
      color: '#fff',
      fontSize:10,
      align:'left'
    },
    splitLine: {
      lineStyle: {
        color: 'rgba(255,255,255,0.22)'
      }
    },
    axisLine: {
      lineStyle: {
        color: 'rgba(255,255,255,0.22)'
      }
    },
    axisLabel: {
      textStyle: {
        color: 'rgba(255,255,255,0.58)'
      }
    }
  },
  series: [{
    data: [],
    type: 'bar',
    barWidth: 20,
    textStyle: {
      color: '#fff'
    },
    itemStyle: {
      normal: {
        color: new echarts.graphic.LinearGradient(
          0, 0, 0, 1,
          [{
              offset: 0,
              color: '#10C7E7'
            },
            {
              offset: 1,
              color: '#2944BE'
            }
          ]
        )
      }
    }
  }]
}
export const TransverseLineOption = {
  tooltip: {
    trigger: 'axis',
    axisPointer: { // 坐标轴指示器，坐标轴触发有效
      type: 'line' // 默认为直线，可选为：'line' | 'shadow'
    }
  },
  xAxis: {
    type: 'value',
    boundaryGap: true,
    areaStyle:{ },
    nameGap: 5,
    nameTextStyle: {
      color: '#fff'
    },
    axisLabel: {
      textStyle: {
        color: 'rgba(255,255,255,0.58)',
        fontSize: 12
      },
      show: true,
      interval: 0
    },
    axisLine: {
      show: true,
      lineStyle: {
        color: 'rgba(255,255,255,0.22)'
      }
    },
    splitLine: {
      lineStyle: {
        color: 'rgba(255,255,255,0.22)'
      }
    },
    axisLine: {
      lineStyle: {
        color: 'rgba(255,255,255,0.22)'
      }
    },
  },
  grid: {
    bottom: 25,
    top: 10,
    left: 10,
    right: 20
  },
  yAxis: {
    type: 'category',
    show: false,
    data: []
  },
  series: [{
    data: [],
    type: 'bar',
    barWidth: 15,
    textStyle: {
      color: '#fff'
    },
    label:{
      show: true,
      position: 'right',
      formatter: '{b}',
      color: '#fff'
    },
    itemStyle: {
      normal: {
        color: new echarts.graphic.LinearGradient(
          0, 0, 0, 1,
          [{
              offset: 0,
              color: '#10C7E7'
            },
            {
              offset: 1,
              color: '#2944BE'
            }
          ]
        )
      }
    }
  }]
}

export const PieOption = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  legend: {
    top: 20,
    orient: 'vertical',
    x: 'right',
    itemHeight: 10,
    itemWidth: 10,
    textStyle: {
      color: '#fff',
      fontSize: 12
    },
    data: ['赣榆区', '东海区', '连云区', '灌云区', '灌南区']
  },
  series: [{
    name: '占比',
    type: 'pie',
    center: ['35%', '50%'],
    radius: ['60%', '80%'],
    avoidLabelOverlap: false,
    label: {
      fontSize: 10,
      normal: {
        show: true,
        position: 'outside'
      },
      emphasis: {
        show: false,
        textStyle: {
          fontSize: '12',
        }
      }
    },
    labelLine: {
      normal: {
        show: true,
        length: 5,
        length2: 5
      }
    },
    color: ['#10C7E7', '#48C292', '#8D57FF', '#CD61AE', '#F6715E', '#F2C338'],
    data: []
  }]
};